/*
 * WatchTreeCellRenderer.java
 * 
 * last update: 14.01.2010 by Stefan Saru
 * 
 * author:	Lucian Ghita Felix(felix@ulise.cs.pub.ro)
 *
 * Obs: N/A
 */


package ide;

import javax.swing.*;
import javax.swing.border.*;
import javax.swing.event.*;
import javax.swing.plaf.*;
import javax.swing.text.*;
import javax.swing.tree.*;
import javax.swing.undo.*;
import javax.swing.text.html.*;
import java.awt.Component;
import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;


@SuppressWarnings("serial")
public class WatchTreeCellRenderer extends JLabel implements TreeCellRenderer
{
	protected boolean selected;

	public Component getTreeCellRendererComponent(JTree tree, Object value,
			boolean selected, boolean expanded,
			boolean leaf, int row,
			boolean hasFocus) {

		Font font;
		String stringValue = tree.convertValueToText(value, selected,
				expanded, leaf, row, hasFocus);

		/* Set the text. */
		WatchTreeNode userObject = (WatchTreeNode)
		((DefaultMutableTreeNode)value).getUserObject();
		String nodeName = userObject.toString();
		//if (userObject.type == ProjectTreeNode.FILETYPE) nodeName = nodeName.substring(nodeName.lastIndexOf(java.io.File.separatorChar) + 1,nodeName.length());
		//if file, display only name (not the absolute path)
		setText(nodeName);
		setToolTipText(userObject.getFQN());
		setIcon(userObject.getIcon());

		if(hasFocus) {
			setForeground(Color.red);
		} else  {
			setForeground(Color.black);
		}
		this.selected = selected;
		revalidate();
		return this;
	}
}
